home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C / Applications / Moscow ML 1.31 / source code / mosml / src / mosmllib / test / vector.sml < prev    next >
Encoding:
Text File  |  1996-07-03  |  2.1 KB  |  64 lines  |  [TEXT/R*ch]

  1. (* test/vector.sml -- some test cases for Vector 
  2.    PS 1994-12-10, 1995-06-14 *)
  3.  
  4. use "auxil.sml";
  5.  
  6. local
  7.     open Vector;
  8.     infix 9 sub;
  9. in
  10.  
  11. val a = fromList [0,1,2,3,4,5,6];
  12. val b = fromList [44,55,66];
  13. val c = fromList [0,1,2,3,4,5,6];
  14.  
  15. val test1 = check'(fn _ => a<>b);
  16. val test2 = check'(fn _ => a=c);
  17.  
  18. val d = tabulate(100, fn i => i mod 7);
  19.  
  20. val test3 = check'(fn _ => d sub 27 = 6);
  21.  
  22. val test4a = (tabulate(maxLen+1, fn i => i) seq "WRONG")
  23.              handle Size => "OK" | _ => "WRONG";
  24.  
  25. val test4b = (tabulate(~1, fn i => i)       seq "WRONG")
  26.              handle Size => "OK" | _ => "WRONG";
  27.  
  28. val test4c = check'(fn _ => length (tabulate(0, fn i => i div 0)) = 0);
  29.  
  30. val test5 = check'(fn _ => length (fromList []) = 0 andalso length a = 7);
  31.  
  32. val test6a = (c sub ~1 seq "WRONG") handle Subscript => "OK" | _ => "WRONG";
  33. val test6b = (c sub 7  seq "WRONG") handle Subscript => "OK" | _ => "WRONG";
  34. val test6c = check'(fn _ => c sub 0 = 0);
  35.  
  36. val e = concat [d, b, d];
  37.  
  38. val test7 = check'(fn _ => length e = 203);
  39.  
  40. val test8 = check'(fn _ => length (concat []) = 0);
  41.  
  42. val f = extract (e, 100, SOME 3);
  43.  
  44. val test9 = check'(fn _ => f = b);
  45.  
  46. val test9a = check'(fn _ => e = extract(e, 0, SOME (length e)) 
  47.             andalso e = extract(e, 0, NONE));
  48. val test9b = check'(fn _ => fromList [] = extract(e, 100, SOME 0));
  49. val test9c = (extract(e, ~1, SOME (length e))  seq "WRONG") 
  50.              handle Subscript => "OK" | _ => "WRONG"
  51. val test9d = (extract(e, length e + 1, SOME 0)  seq "WRONG") 
  52.              handle Subscript => "OK" | _ => "WRONG"
  53. val test9e = (extract(e, 0, SOME (length e+1)) seq "WRONG") 
  54.              handle Subscript => "OK" | _ => "WRONG"
  55. val test9f = (extract(e, 20, SOME ~1)        seq "WRONG") 
  56.              handle Subscript => "OK" | _ => "WRONG"
  57. val test9g = (extract(e, ~1, NONE)  seq "WRONG") 
  58.              handle Subscript => "OK" | _ => "WRONG"
  59. val test9h = (extract(e, length e + 1, NONE)  seq "WRONG") 
  60.              handle Subscript => "OK" | _ => "WRONG"
  61. val test9i = check'(fn _ => fromList [] = extract(e, length e, SOME 0)
  62.             andalso fromList [] = extract(e, length e, NONE));
  63. end;
  64.